package xyz.zyl2020.securityjwt.controller;

import org.junit.platform.commons.util.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import xyz.zyl2020.securityjwt.utils.JwtUtil;

/**
 * @author ZhuYinglong
 * @date 2020/8/22 0022
 */
@Controller
public class RouteController {

    @RequestMapping({"/", "/index"})
    public String index() {
        return "index";
    }

    @GetMapping("/loginPage")
    public String loginPage() {
        return "login";
    }

    @GetMapping("/currentUser")
    public String getUsername(String token) {
        if (StringUtils.isBlank(token)) {
            return "";
        }
        return JwtUtil.getUsername(token);
    }
}
